/*
** fill_obj_fcts1.c for  in /home/chreti_m//projet/RAYTRACER/init_cnf_file
** 
** Made by max chretien
** Login   <chreti_m@epitech.net>
** 
** Started on  Mon Apr 30 02:20:04 2012 max chretien
** Last update Mon Apr 30 17:16:12 2012 canh-kiet le
*/

#include	"rt.h"

void		obj_pos(char **tab, t_obj *obj, int line_err)
{
  int		i;

  if (cnt_params(tab) != 4)
    disp_err(tab[0], line_err, "Only need 3 arguments.\n");
  i = 1;
  while (tab[i])
    {
      if (!my_str_isnum(tab[i++]))
	disp_err(tab[0], line_err, "Argument must be only numbers.\n");
    }
  obj->pos.x = atof(tab[1]);
  obj->pos.y = atof(tab[2]);
  obj->pos.z = atof(tab[3]);
}

void		obj_rot(char **tab, t_obj *obj, int line_err)
{
  int		i;

  if (cnt_params(tab) != 4)
    disp_err(tab[0], line_err, "Only need 3 arguments.\n");
  i = 1;
  while (tab[i])
    {
      if (!my_str_isnum(tab[i++]))
	disp_err(tab[0], line_err, "Argument must be only numbers.\n");
    }
  obj->rot.x = atof(tab[1]);
  obj->rot.y = atof(tab[2]);
  obj->rot.z = atof(tab[3]);
}

void		obj_lim(char **tab, t_obj *obj, int line_err)
{
  if (cnt_params(tab) != 2)
    disp_err(tab[0], line_err, "Only need 1 argument.\n");
  if (!my_str_isnum(tab[1]))
    disp_err(tab[0], line_err, "Argument must be only numbers.\n");
  obj->lim = atoi(tab[1]);
}

void		obj_data(char **tab, t_obj *obj, int line_err)
{
  int		i;

  if (cnt_params(tab) != 4)
    disp_err(tab[0], line_err, "Only need 3 arguments.\n");
  i = 1;
  while (tab[i])
    {
      if (!my_str_isnum(tab[i++]))
	disp_err(tab[0], line_err, "Argument must be only numbers.\n");
    }
  obj->data.x = atof(tab[1]);
  obj->data.y = atof(tab[2]);
  obj->data.z = atof(tab[3]);
}

void		obj_n_ref(char **tab, t_obj *obj, int line_err)
{
  if (cnt_params(tab) != 2)
    disp_err(tab[0], line_err, "Only need 1 argument.\n");
  if (!my_str_isnum(tab[1]))
    disp_err(tab[0], line_err, "Argument must be only numbers.\n");
  obj->n_refrac = atof(tab[1]);
}
